package org.anddev.andengine.extra;

import org.anddev.andengine.entity.layer.Layer;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.Scene.IOnAreaTouchListener;
import org.anddev.andengine.entity.scene.Scene.IOnSceneTouchListener;
import org.anddev.andengine.input.touch.TouchEvent;
import org.anddev.andengine.ui.activity.BaseGameActivity;

public abstract class ExtScene extends Scene implements IExtScene, IOnAreaTouchListener, IOnSceneTouchListener {
	protected BaseGameActivity mGameActivity;
	
	public ExtScene() {
		super(0);
		this.mGameActivity = (BaseGameActivity) Enviroment.getInstance().getContext();
		
		super.attachChild(new Layer());
		super.attachChild(new Layer());
		super.attachChild(new Layer());
		super.attachChild(new FadeLayer());
		
        setOnAreaTouchListener(this);
        setOnSceneTouchListener(this);
        
        createScene();
	}
	
	@Override
	public boolean onAreaTouched(TouchEvent pSceneTouchEvent, ITouchArea pTouchArea, float pTouchAreaLocalX, float pTouchAreaLocalY) {
		if (pSceneTouchEvent.isActionDown()) {
			manageAreaTouch(pTouchArea);
			return true;
		}
		return false;
	}
	
	@Override
	public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
		if (pSceneTouchEvent.isActionDown()) {
			manageSceneTouch(pSceneTouchEvent);
			return true;
		}
		return false;
	}
	
}
